<?php
/**
 * Created by PhpStorm.
 * User: 86182
 * Date: 2020/6/26
 * Time: 14:35
 */

namespace App\Serves;
use App\Utils\Factory;
use Illuminate\Support\Facades\Cache;
class SendSmsServe
{
    public static function sendSms($phone, $type){
        $code = mt_rand(000000, 999999);
//        $class = "App\Utils\sms\\".ucfirst($type)."Sms";
//        $sms_res = $class::send($phone, $code);

        $classType = Factory::smsClassType();
        $class = Factory::getClass($type, $classType, [], false);
//var_dump($class);exit;

        $sms_res = $class::send($phone, $code);

        if( $sms_res ){
            //redis扩展
            $r = Cache::put(config('user.pre_sms_').$phone,$code,6000);
        }
        return $sms_res;
    }
}